package cn.wolfcode.car.business.service.impl;
import cn.wolfcode.car.business.domain.CustomerLinkMane;
import cn.wolfcode.car.business.domain.CustomerVisit;
import cn.wolfcode.car.business.mapper.CustomerVisitMapper;
import cn.wolfcode.car.business.query.CustomerVisitQuery;
import cn.wolfcode.car.business.service.ICustomerVisitService;
import cn.wolfcode.car.common.base.page.TablePageInfo;
import cn.wolfcode.car.shiro.ShiroUtils;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CustomerVisitServiceImpl implements ICustomerVisitService {

    @Autowired
    private CustomerVisitMapper customerVisitMapper;

    @Override
    public void save(CustomerVisit customerVisit) {
        customerVisit.setInputTime(new Date());
        customerVisit.setInputUser(ShiroUtils.getUser().getId());
        customerVisitMapper.insert(customerVisit);
    }

    @Override
    public TablePageInfo<CustomerVisit> query(CustomerVisitQuery qo) {
        PageHelper.startPage(qo.getPageNum(), qo.getPageSize());
        List<CustomerVisit> customerVisits = customerVisitMapper.selectForList(qo);
        return new TablePageInfo<CustomerVisit>(customerVisits);
    }

    @Override
    public List<CustomerLinkMane> customerBylinkman(Long id) {
        List<CustomerLinkMane> customerLinkManes = customerVisitMapper.customerBylinkman(id);
        return customerLinkManes;
    }
}
